package com.xmy.cultivate.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.TrackDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xmy.cultivate.entity.TrackNum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author min
 * @since 2022-12-27
 */
@Mapper
public interface TrackDetailMapper extends BaseMapper<TrackDetail> {


    @Select("select sourse_id from track_detail ${ew.customSqlSegment}")
    public abstract List<Long> getSourceIdList(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("SELECT \n" +
            "   teacher_id,add_date, \n" +
            "   SUM(count) AS allNumber, \n" +
            "   SUM(CASE WHEN add_date BETWEEN #{beginDate} AND #{endDate} THEN count ELSE 0 END) AS nowNumber \n" +
            "FROM \n" +
            "   deal_info where teacher_id = #{teacher_id} and deleted = 0")
    public abstract TrackNum getTrackNum(@Param("beginDate")String beginDate,@Param("endDate")String endDate,@Param("teacher_id")String teacherId);
}
